package com.jzit.networkproject

import android.app.Application
import android.content.Intent
import androidx.lifecycle.AndroidViewModel
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import java.util.ArrayList

/**
 *@ProjectName:Asia-seller
 *@Email:lannidi@163.com
 *@Author:周雪成
 *@CreateTime:2021/12/16/2:44 下午
 *@Name:BaseModel
 */
open class BaseModel(app: Application) : AndroidViewModel(app) {

    suspend fun <T> checkCode(code: Int, message: String, data: T?): T? {
        return when (code) {
            NetStatusCode.FALL.code -> {
                null
            }
            NetStatusCode.SUCCESS.code -> {
                data
            }
            NetStatusCode.NO_LOGIN.code -> {
                //login
                null
            }
            NetStatusCode.USER_NOT.code -> {
                null
            }
            NetStatusCode.LOGIN.code -> {
                null
            }
            NetStatusCode.CONTROL.code -> {
                null
            }
            NetStatusCode.CODE_10.code -> {
                null
            }
            else -> null
        }
    }


    private var mCurPage = 1

    private val mDisposable = CompositeDisposable()

    override fun onCleared() {
        mDisposable.dispose()
    }

    open fun addDisposable(disposable: Disposable?) {
        mDisposable.add(disposable!!)
    }
}